package com.dy.design_pattern_study.composite_pattern.dome2;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-12
 * @Content 公司抽象类
 */
public abstract class Company {
    protected String name;

    public Company(String name) {
        this.name = name;
    }

    public abstract void add(Company company);//增加
    public abstract void remove(Company company);//移除
    public abstract void display(int depth);//显示

    /**
     * 不同的部门可以行使不同的职责
     */
    public abstract void lineOfDuty();//履行职责

    /**
     * 打印 子节点
     * @param depth
     * @return
     */
    public String printStr(int depth){
        StringBuffer buffer = new StringBuffer("-");
        for (int i = 0; i < depth; i++) {
            buffer.append("-");
        }
        buffer.append(name);
        //System.out.println();
        return buffer.toString();
    }
}
